/******************************************************************
 * Copyright (c) 2007 - 2007, Simon Guerard, All rights reserved.
 * 
 * Projet de jeu de course au large.
 * 
 * This File is part of Sail-Race
 * 
 * Sail-Race is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 * 
 * Sail-Race is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with Sail-Race; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */
package net.simcafamily.sailrace.core;

import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.stereotype.Component;

@Component("session")
public class Session {
	// liste de textes
	private ArrayList<String> textes = new ArrayList<String>();;
	// liste d'erreurs
	private ArrayList<String> erreurs = new ArrayList<String>();

	private final HashMap<String, Object> attributes = new HashMap<String, Object>();

	// getters-setters
	/**
	 * @return the attributes
	 */
	public final Object getAttribute(final String pKey) {
		return attributes.get(pKey);
	}

	/**
	 * @return the attributes
	 */
	public final Boolean getBooleanAttribute(final String pKey) {
		if (attributes.get(pKey) instanceof Boolean) {
			return (Boolean) attributes.get(pKey);
		}
		return Boolean.getBoolean(String.valueOf(attributes.get(pKey)));
	}

	public ArrayList<String> getErreurs() {
		return erreurs;
	}

	/**
	 * @return the attributes
	 */
	public final Integer getIntAttribute(final String pKey) {
		return Integer.getInteger(String.valueOf(attributes.get(pKey)));
	}

	/**
	 * @return the attributes
	 */
	public final String getStringAttribute(final String pKey) {
		return String.valueOf(attributes.get(pKey));
	}

	public ArrayList<String> getTextes() {
		return textes;
	}

	/**
	 * @param pAttributes
	 *            the attributes to set
	 */
	public final void setAttribute(final String pKey, final Object pValeur) {
		attributes.put(pKey, pValeur);
	}

	public void setErreurs(final ArrayList<String> erreurs) {
		this.erreurs = erreurs;
	}

	public void setTextes(final ArrayList<String> textes) {
		this.textes = textes;
	}

}
